<template>
  <div class="goods_item" @click="itemClick">
    <img :src="goods.show.img" alt="" />
    <div class="info">
      <p>{{ goods.title }}</p>
      <span class="price">￥{{ goods.price }}</span>
      <span class="collect">{{ goods.cfav }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'GoodsListItem',
  props: {
    goods: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  methods: {
    /**
     * 点击跳转到详情页
     */
    itemClick () {
      this.$router.push(`/detail/${this.goods.iid}`)
    }
  }
}
</script>

<style lang="scss" scoped>
.goods_item {
  width: 48%;
  position: relative;
  padding-bottom: 40px;

  img {
    width: 100%;
    border-radius: 2px;
  }

  .info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 5px;
    font-size: 12px;
    text-align: center;

    p {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      margin-bottom: 3px;
    }

    .price {
      margin-right: 20px;
      color: $--color-high-text;
    }

    .collect {
      position: relative;

      &::before {
        content: '';
        position: absolute;
        left: -15px;
        top: 0;
        width: 14px;
        height: 14px;
        background: url('~@/assets/images/common/collect.svg') 0 0/14px 14px;
      }
    }
  }
}
</style>
